package com.mid;

/**
 * Created by Lxk on 2019/5/13.
 */
public class Solution55 {

    public boolean canJump(int[] nums) {
        if(nums == null || nums.length<=1){
            return true;
        }
        int max = 0;
        int cur = 0;

        for(int i = cur; i <= max && i < nums.length ; i++){
            if(i + nums[i] > max){
                max = i + nums[i];
                if(max >= nums.length-1){
                    return true;
                }
            }
        }
        return max < nums.length-1 ? false : true;
    }

    public static void main(String[] args) {
//        int[] steps = {2,3,1,1,4};
        int[] steps = {3,2,1,0,4};
//        int[] steps = {1,1,1,0};
//        System.out.println(canJump(steps));
    }

}
